<template>
  <div class="container"
       v-if="card_info.style_pic||card_info.goods_image">
    <div class="list-item"
         :style="{'backgroundImage':'url('+(img_url+(card_info.style_pic||card_info.goods_image))+')'}">
      <div class="card-name">
        {{card_info.name}}
      </div>
      <div class="dec">
        {{card_info.describe}}
      </div>
      <div class="btm-bar">
        {{card_info.validity_start_time}}~{{card_info.validity_end_time}}
      </div>
    </div>
  </div>
</template>

<script>
import common from '@/assets/js/mmk_common.js'
export default {
  data () {
    return {
      base_url: common.image_resource,
      img_url: common.image_response,
    }
  },
  props: ["card_info"],
  watch: {
    card_info () {
      if (this.card_info.validity_start_time) {
        this.card_info.validity_start_time = new Date(this.card_info.validity_start_time * 1000).Format("yyyy.MM.dd")
      }
      if (this.card_info.validity_end_time) {
        this.card_info.validity_end_time = new Date(this.card_info.validity_end_time * 1000).Format("yyyy.MM.dd")
      }
      this.$forceUpdate()
    }
  },

}
</script>

<style lang="less" scoped>
.container {
  .list-item {
    height: 155px;
    border-radius: 8px;
    padding: 20px;
    box-sizing: border-box;
    position: relative;
    background-repeat: no-repeat;
    background-size: cover;
    .card-name {
      font-size: 18px;
      font-family: "PingFangSC-Medium", "PingFang SC";
      font-weight: 500;
      color: rgba(255, 255, 255, 1);
      line-height: 25px;
    }
    .dec {
      font-size: 14px;
      font-family: "PingFangSC-Regular", "PingFang SC";
      font-weight: 400;
      color: rgba(255, 255, 255, 1);
      line-height: 20px;
      margin-top: 5px;
    }
    .btm-bar {
      width: 100%;
      height: 44px;
      background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.48) 0%,
        rgba(255, 255, 255, 0.21) 100%
      );
      font-size: 12px;
      font-family: "PingFangSC-Regular", "PingFang SC";
      font-weight: 400;
      color: rgba(94, 46, 28, 1);
      line-height: 44px;
      padding-left: 20px;
      position: absolute;
      bottom: 0;
      left: 0;
    }
  }
}
</style>